//
//  ShiTiQKCKeyWordViewController.m
//  MyProject
//
//  Created by Pei on 16/7/31.
//  Copyright © 2016年 Xiaobo Pei. All rights reserved.
//

#import "ShiTiQKCKeyWordViewController.h"

@interface ShiTiQKCKeyWordViewController (){
    UITextField *inputText;
}

@end

@implementation ShiTiQKCKeyWordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 22)];
    [rightBtn setTitle:@"保存" forState:UIControlStateNormal];
    [rightBtn setTitleColor:kBlueColor forState:UIControlStateNormal];
    rightBtn.titleLabel.font = kAppFont(Home_Big_Size);
    [rightBtn addTarget:self action:@selector(rightBtnAcion) forControlEvents:UIControlEventTouchUpInside];
    [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:rightBtn]];
    
    UIView *backView = [[UIView alloc] init];
    backView.frame = CGRectMake(0.0f, 0.0f, kDeviceWidth, 40.0f);
    backView.backgroundColor = kWhiteColor;
    [self.view addSubview:backView];
    
    inputText = [[UITextField alloc] init];
    inputText.frame = CGRectMake(10.0f, 10.0f, kDeviceWidth-20.0f, 20.0f);
    inputText.backgroundColor = [UIColor clearColor];
    inputText.placeholder = @"请输入关键字";
    [backView addSubview:inputText];

}

- (void)rightBtnAcion{
    if (inputText.text != nil && inputText.text.length > 0) {
        if ([self.delegate respondsToSelector:@selector(passValue:)]) {
            [self.delegate passValue:inputText.text];
        }
        [self.navigationController popViewControllerAnimated:YES];
    }else
    {
        if ([self.delegate respondsToSelector:@selector(passValue:)]) {
            [self.delegate passValue:@""];
        }
        [self.navigationController popViewControllerAnimated:YES];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}


@end
